package org.example.infrastructure.repository.orm.redis;

import lombok.RequiredArgsConstructor;
import org.example.domain.repository.RegistryCacheRepository;
import org.redisson.api.RBloomFilter;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class RedisRegistryCacheRepository implements RegistryCacheRepository {
    private final RBloomFilter<String> userRegistryCacheBloomFilter;

    @Override
    public void addRedisRegistryCache(String userName) {
        userRegistryCacheBloomFilter.add(userName);
    }

    /**
     * ture 存在，false不存在
     *
     * @param userName
     * @return
     */
    @Override
    public Boolean hasRedisRegistryCache(String userName) {
        return userRegistryCacheBloomFilter.contains(userName);
    }


}
